<?php
Class Dorps_model extends CI_Model {
  
  function getdorpbyid($id) {
    $sql = "SELECT p.*, pp.id_pais FROM Programas p inner join ProgramasPais pp on  pp.id_programa = p.id_programa where p.id_programa = '$id'";
    $query = $this->db->query($sql);
    return $query->result();
  }

  function getdorpsbycountry($id) {
    $sql = "SELECT p.* FROM Programas p inner join ProgramasPais pp on  pp.id_programa = p.id_programa where pp.id_pais = '$id'";
    $query = $this->db->query($sql);
    return $query->result();
  }

  //Saves an user into the database
  function save($dorpid, $dorpname, $dorpcountry, $dorpdir) {
	  $sql = "Save_Dorp '$dorpid', '$dorpname', '$dorpcountry', '$dorpdir'";
    $query = $this->db->query($sql);
    return $query->num_rows();
  }

}
?>